#ifndef SENSOR_CHANNELS_H
#define SENSOR_CHANNELS_H

#include "types.h"
#include "stm32f10x.h"

#define PHYSENSOR_CHANNELS	3

typedef enum {
	CHANNEL_TEMP,	// temperature: analog or digital
	CHANNEL_TIME,	// interrupt time
	CHANNEL_FREQ,	// frequency input
	CHANNEL_HYGR,	// hygrometer 
} ChannelMode_t;

typedef struct {
	GPIO_TypeDef *Port;
	uint16_t PinMask;
} IO_t;

typedef struct {
	IO_t 	Power3V3Ctrl;
	IO_t	Power5VCtrl;
	IO_t	PowerPullupCtrl;
	IO_t	DataLineA;
	IO_t	DataLineB;
} SensorChannelHw_t;

// Hardware Pinout config
// typedef struct {
// 	GPIO_TypeDef *PowerCtrlPort;
// 	uint16_t PowerCtrlPinMask;
// 	
// 	GPIO_TypeDef *VoltPort;
// 	uint16_t VoltPinMask;
// 	
// 	GPIO_TypeDef *AIOPort;
// 	uint16_t AIOPinMask;
// 	uint8_t AIOPortSource;
// 	uint8_t AIOPinSource;	
// } SensorHwChannelConfig_t;

// extern const SensorHwChannelConfig_t ChannelHwInfo[PHYSENSOR_CHANNELS];
extern const SensorChannelHw_t channelHwInfo[PHYSENSOR_CHANNELS];

extern int OpenChannel(int channel, ChannelMode_t mode);
extern int isChannelEnable(int channel);
extern int CloseChannel(int channel);
extern void OutputChannelData(int channel);
extern int SetTemperatureSensorReadPeriodInMillisecond(int channel, int millisecond);

#endif // ifndef SENSOR_CHANNELS_H
